import os
import folium
import numpy as np
import json

from folium.plugins import HeatMap

filename1 = "C:/Users/jiarui/Desktop/数学建模/数学建模美赛集训/第一轮/forecast.json"
with open(filename1, 'r', encoding='utf-8') as file: data_hot = json.load(file)
filename2 = "C:/Users/jiarui/Desktop/数学建模/数学建模美赛集训/第一轮/Drug.json"
with open(filename2, 'r', encoding='utf-8') as file: data_local = json.load(file)

Dx = []
Dy = []
Hot = []
# 表示年份和需要统计的数据 0为H 1为F 2为O
year = 5
index = 2

for X in data_hot:
    Dx.append(float(data_local[X][str(2008 + year)]['Local'][0][0]))
    Dy.append(float(data_local[X][str(2008 + year)]['Local'][0][1]))
    Hot.append(float(sum(data_hot[X][year])))
draw_data = [[Dx[i], Dy[i], Hot[i]] for i in range(380)]

m = folium.Map(location=[38, -80], zoom_start=2.5)
HeatMap(draw_data).add_to(m)

m.save(os.path.join(r'C:/Users/jiarui/Desktop/数学建模/数学建模美赛集训/第一轮/', 'Heatmap1.html'))
